// main.cpp : Defines the entry point for the console application.
#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
//#include "TestUtils.h"
//#include "PermutationsUnitTests.h"
#include "Permutations.h"
#include "Permutation.h"
#include "Helpers.h"
#include "filesystem.h"

using std::string;
using std::iostream;
using std::endl;

int main(int argc, char* argv[])
{
	try
	{
		if (argc < 4)
		{
			Logger::LogMessage("Usage: permutations.exe [chain file name] [parmeters file name] [output folder name]");
			return -1;
		}

#if 1
		


		ChainParser chainFile(argv[1]);
		WinInputParmetersParser inputFile(argv[2]);
		
		//create a seed for the random numbers generation
		srand((unsigned int)time(NULL));

		//navigate to the output directory
		WinFileSystem fileSystem;
		fileSystem.SetTheCurrentDirectory(argv[3]);
		
		Debug::changeDebugStream(false);	
		
		Permutations *permutations = Permutations::CreatePermutationsObject(chainFile, inputFile);

		if (NULL == permutations)
		{
			Logger::LogMessage("unable to create permutations object, exiting.");
			return 0;
		}
		
		permutations->Run();		
#endif
	}
	catch(std::exception *e)
	{
		std::string s = "Unhandled exception occurred. Details: ";
		Logger::LogMessage(s + e->what());
	}

			 
	Logger::LogMessage("Finished permutations run");
	return 0;
}

